use std::thread;
use crate::ltools::ltime;
pub mod lencrypted;

pub mod lerror;
pub mod ltools;

#[macro_export]
macro_rules! log_info {
    ($x:expr) => (
        $crate::print_log(4, $x);
    );
}

#[macro_export]
macro_rules! log_error {
    ($x:expr) => (
        $crate::print_log(6, $x);
    );
}

#[macro_export]
macro_rules! log_warn {
    ($x:expr) => (
        $crate::print_log(5, $x);
    );
}

pub fn print_log(log_level: u8, msg: impl AsRef<str>) {
    println!("{}  {}: {}",ltime::get_now_format_time(), get_thread_info(), msg.as_ref())
}

fn get_thread_info() -> String {
    let cuth = thread::current();
    let mut cname = "";
    if let Some(t) = cuth.name() { cname = t };
    format!("{:?}({:?})", cname, cuth.id())
}
